package common.impl;

import net.sf.json.JSONObject;

public class TencentMapAPI {
	private final static String api_url="http://apis.map.qq.com/ws/geocoder/v1/?location=LOCATION&key=AINBZ-7O3H4-CGMUJ-DDM3U-7NGHO-ASBD6&get_poi=1";
	
	
	public final static JSONObject find_tenctenMap_msg(String localtion) throws Exception{
		JSONObject jobj = new JSONObject();
		String url = api_url.replace("LOCATION", localtion);
		String result = MicroBlog.get(url, null);
		jobj = JSONObject.fromObject(result);
		boolean api_ok = false;
		if(jobj.containsKey("status") && jobj.getInt("status") == 0){
			if(jobj.containsKey("result")){
				jobj = jobj.getJSONObject("result");
				if(jobj.containsKey("ad_info")){
					jobj = jobj.getJSONObject("ad_info");
					api_ok = true;
				}
			}
		}
		jobj.put("api_ok", api_ok);
		return jobj;
	}
}
